<?php
	
	namespace Api\Controller;
	use Think\Controller;
	
	/**
	 * App文章控制器
	 * @package default
	 * @author  Lwbang
	 */
	
	class ArticleController extends TokenController{
		
		private $model; //返回当前文章模型
		
		/**
		 * 创建article模型的引用
		 * @return void
		 * @author Lwbang  
		 */
		protected function _initialize() {
			$this->model = M('Article');
		}
		
		/**
		 * 返回首页展示文章
		 * @return String
		 * @author Lwbang  
		 */
		public function indexArt(){
			//每页显示条数
			$pageRow = I('get.row',5,'intval');
			//当前页
			$page = I('get.page',1,'intval');
			//返回首页显示数据
			$data = $this->model->field('post_aid,post_time,post_title,post_excerpt')->order('post_time Desc')->page($page,$pageRow)->select();
			//将文章内容减少
			foreach($data as $key=>$d){
				$data[$key]['post_excerpt'] = mb_substr($d['post_excerpt'],0,70,'utf-8');
				$data[$key]['post_time'] = date('Y-m-d H:i:s',$d['post_time']);
			}
			$this->ajaxReturn($data);
			
			
		}
		
		
		
		
	}
	